package algo;

import objects.Point;

public class Distance {

	/**
	 * Computes the distance in meters between 2 points
	 * @param p1
	 * @param p2
	 * @return
	 */
	public static float computeDistance(Point p1, Point p2) {
		
		return (float)Math.sqrt(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2) + Math.pow(p1.getZ() - p2.getZ(), 2));
	}
	
	
	/**
	 * Computes the distance between a point and the perimeter of a circle
	 * @param p1 : point
	 * @param p2 : center of the circle
	 * @param radius : radius of the circle
	 * @return
	 */
	public static float computeDistance(Point p1, Point p2, float radius) {
		
		return Math.abs((float)Math.sqrt(Math.pow(p1.getX() - p2.getX(), 2) + Math.pow(p1.getY() - p2.getY(), 2)) - radius);
	}
}
